package com.gaohe.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gaohe.common.Result;
import com.gaohe.mapper.CourseMapper;
import com.gaohe.pojo.Course;
import com.gaohe.service.CourseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.awt.color.CMMException;
import java.util.List;

@Slf4j
@Service
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> implements CourseService {
    @Autowired
    private CourseMapper courseMapper;

    @Override
    public Result listCourseByMemberId(Long memberId, String type, Integer page, Integer pageSize) {
        // mybatis  分页
        //page 当前页码
        //pageSize 每页条目数
        //limit 1 , 3
        //起始索引  = （page -1）* pageSize
        Integer index = (page - 1) * pageSize;
        List<Course> courseList = courseMapper.listCourseByMemberId(memberId, type, index, pageSize);
        return Result.success(courseList);
    }
}
